package com.situ.mall.admin.config;

import com.situ.mall.admin.Interceptor.LoginInterceptor;
import com.situ.mall.admin.util.Constants;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//spring mvc 配置类
@Configuration
public class MyMVCConfig  implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/checkPhone","/forgetPassword","/image","/login","/captcha","/api/**","/css/**","/images/**","/js/**","/lib/**","/page/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler(Constants.UPLOAD_PATH_PREFIX+"**").
                addResourceLocations("file:D:\\test\\");
    }
}
